<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>让球一赔小于1.5历史开奖</title>
    <script src="../static/js/jquery-3.7.1.min.js" type="text/javascript"></script>
    <style>
    table {
        border-collapse: collapse; /*合并边框*/
        width: 100%; /*设置表格宽度*/
    }

    th, td {
        border: 1px solid black; /*设置边框线样式、颜色和大小*/
        padding: 8px; /*设置内边距*/

    }
    thead>td{
             text-align: center;
        }
        tbody>td{
             text-align: left;
        }

        .kj{
            display: flex;
            justify-content: space-between;
        }
        .kj>div{
            margin: 0;
            padding: 0 5px;
            border: 2px solid #D4D4D4;
            width: 100%;
            height: 100%;
            text-align: center;
        }
        .zhong{
            background-color: red;
            color: white;
        }
        .but{
            display: flex;justify-content: space-between;
        }
        .but>div{
            border: 1px solid green;cursor:pointer
        }
        .xuan{
            background-color: red;
            color: white;
        }

        .hidden_display {
          display: none;
        }
</style>

</head>
<body>
<div>
    年份：<input type="text" id="year" value="2024"/>
    让球:<select id="rang">
            <option value="-1">-1</option>
            <option value="+1">+1</option>
        </select>
    <input type="button" onclick="load()" value="查询"/>
</div>
<table id="t">
    <caption>每期让球一赔小于1.5最小的一场历史开奖数据</caption>
<thead style="text-align: center">
<tr>
    <td rowspan="2">序号</td>
    <td rowspan="2">日期</td>
    <td rowspan="2">场次</td>
    <td rowspan="2">让球</td>
    <td rowspan="2">比赛</td>
    <td rowspan="2">半场比分</td>
    <td rowspan="2">全场比分</td>
    <td colspan="5">开奖</td>
    <td rowspan="2">操作</td>
</tr>
<tr>
    <td>
        <div class="but">
            <div class="xuan" onclick="showspf(0)" id="spf">胜平负</div>
            <div onclick="showspf(1)" id="pei">一二三赔</div>
        </div>
    </td>
    <td>让球胜平负</td>
    <td>半全场</td>
    <td>总进球</td>
    <td>比分</td>
</tr>
</thead>
   <tbody>
{#        <tr>#}
{#            <td>日期</td>#}
{#            <td>场次</td>#}
{#            <td>比赛</td>#}
{#            <td>半场比分</td>#}
{#            <td>全场比分</td>#}
{#            <td>#}
{#                <div class="kj">#}
{#                    <div>2.1</div>#}
{#                    <div class="zhong">2.2</div>#}
{#                    <div>2.3</div>#}
{#                </div>#}
{#            </td>#}
{#            <td>让球胜平负</td>#}
{#            <td>半全场</td>#}
{#            <td>总进球</td>#}
{#            <td>比分</td>#}
{#            <td>操作</td>#}
{#        </tr>#}
   </tbody>
</table>
</body>

<script type="text/javascript">
    $(function () {
       load();
    });

    // 加载数据
    function load() {
        var year = $('#year').val();
        var rang = $('#rang').val();
        //加载前清空之前页面的显示
        $("#t>tbody").html("");
        // 获取后台数据
         $.get('/kj_ds', {"year": year,"rang":rang}, function (r) {
            var arr = new Array();
            for (var i = 0; i < r.length; i++) {
                var m = r[i].base_info;
                var kj = r[i].kaij;

                var bettingSingle = '';
                if(m.bettingSingle == 1){
                    bettingSingle = '单关';
                }
                arr.push("<tr>");
                arr.push("<td>"+(i+1)+"</td>");
                arr.push("<td>"+m.matchTime+"</td>");
                arr.push("<td>"+m.matchNumStr+"&nbsp;"+bettingSingle+"</td>");
                arr.push("<td>"+m.goalLine+"</td>");
                arr.push("<td>"+m.homeTeam+"vs"+m.awayTeam+"</td>");
                arr.push("<td>"+kj.sectionsNo1+"</td>");
                arr.push("<td>"+kj.sectionsNo999+"</td>");
                if(kj.HAD!=undefined){
                    arr.push("<td>");
                    arr.push(...showkaij(kj.HAD));
                    arr.push("</td>");
                }else{
                   arr.push("<td></td>");
                }
                if(kj.HHAD!=undefined){
                    arr.push("<td>");
                    arr.push(...showkaij(kj.HHAD));
                    arr.push("</td>");
                }else{
                   arr.push("<td></td>");
                }
                if(kj.HAFU!=undefined){
                    arr.push("<td>"+kj.HAFU.combinationDesc+"["+kj.HAFU.odds+"]"+"</td>");
                }else{
                   arr.push("<td></td>");
                }
                arr.push("<td>"+kj.TTG.combinationDesc+"["+kj.TTG.odds+"]"+"</td>");
                arr.push("<td>"+kj.CRS.combinationDesc+"["+kj.CRS.odds+"]"+"</td>");
                arr.push("<td>"+m.matchTime+"</td>");

                arr.push();

                arr.push("</tr>");

            }
             $("#t").append(arr.join(" "));
         });
    }
    // 显示开奖标记
    function showkaij(d) {
        var arr = new Array();
        arr.push("<div class='kj kjspf'>");
        for(var a of d.rs){
            if(a[0]==a[2]){
             arr.push("<div class='zhong'>"+a[1]+"</div>");
            }else{
                arr.push("<div>"+a[1]+"</div>");
            }
        }
        arr.push("</div>");

        arr.push("<div class='kj hidden_display kjpei'>");
        var combination = d.pei.combination;
        for(var a of d.pei.peilist){
            if(combination==a[0]){
             arr.push("<div class='zhong'>"+a[1]+"</div>");
            }else{
                arr.push("<div>"+a[1]+"</div>");
            }
        }
        arr.push("</div>");
        return arr;
    }
    
    function showspf(a) {
        //默认胜平负
        if(a==0){
            $('#spf').addClass("xuan");
            $('#pei').removeClass("xuan");
            $('.kjpei').addClass("hidden_display");
            $('.kjspf').removeClass("hidden_display");
        }else {
            $('#pei').addClass("xuan");
            $('#spf').removeClass("xuan");
            $('.kjspf').addClass("hidden_display");
            $('.kjpei').removeClass("hidden_display");
        }

    }
</script>
</html>